﻿// -----------------------------------------------------------------------
// <copyright company="Christoph van der Fecht - VDsoft">
// Copyright (C) Christoph van der Fecht - VDsoft - All Rights Reserved
// Unauthorized copying of this file, via any medium is strictly prohibited,
// unless it is communicated and authorized by the copyright owner.
// </copyright>
// -----------------------------------------------------------------------

using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Runtime.CompilerServices;

namespace SeriesManager.Model
{
	/// <summary>
	/// Season for a banner
	/// </summary>
	public class BannerSeason : INotifyPropertyChanged
	{
		/// <summary>
		/// The Season.
		/// </summary>
		private int season = 0;

		/// <summary>
		/// The Banners.
		/// </summary>
		private ObservableCollection<Banner> banners = new ObservableCollection<Banner>();

		/// <summary>
		/// Initializes a new instance of the <see cref="BannerSeason"/> class.
		/// </summary>
		public BannerSeason()
		{
		}

		/// <summary>
		/// Occurs when a property changed its vaule.
		/// </summary>
		public event PropertyChangedEventHandler PropertyChanged;

		/// <summary>
		/// Gets or sets the Season.
		/// </summary>
		public int Season
		{
			get
			{
				return this.season;
			}

			set
			{
				if (value == this.season)
				{
					return;
				}

				this.season = value;
				this.RaisePropertyChanged();
			}
		}

		/// <summary>
		/// Gets or sets the Banners.
		/// </summary>
		public ObservableCollection<Banner> Banners
		{
			get
			{
				return this.banners;
			}

			set
			{
				if (value == this.banners)
				{
					return;
				}

				this.banners = value;
			}
		}

		/// <summary>
		/// Adds a banner to the season.
		/// </summary>
		/// <param name="toAdd">Banner to add.</param>
		public void AddBanner(Banner toAdd)
		{
			if (toAdd == null)
			{
				throw new ArgumentNullException("toAdd", "Provided banner must not be null.");
			}

			this.Banners.Add(toAdd);
		}

		/// <summary>
		/// Raises the <see cref="PropertyChanged"/> event.
		/// </summary>
		/// <param name="propertyName">Name of the property that changed its value.</param>
		private void RaisePropertyChanged([CallerMemberName]string propertyName = "")
		{
			if (this.PropertyChanged != null)
			{
				this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
			}
		}
	}
}
